﻿<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@page import="com.aiflow.Action.DictionaryAction"%>
<html>
<head>
	<%
		String userConfId = request.getParameter("userConf");
	%>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript">
	var editAlarmproFormPanel = null;
	
		$(document).ready(function(){
			// 工具栏
		    var toolbar = new Ext.Toolbar({
		    	renderTo: 'editAlarmproToolBarDiv',
		    	items: [
				    new Ext.Button({
					    id: 'editAlarmpro-save-button',
						text: '保存',
						iconCls: 'tick'
					}),
					new Ext.Button({
					    id: 'editAlarmpro-cancel-button',
						text: '取消',
						iconCls: 'cancel'
					})
				]
			});
               
               // 告警类型数据源
               var alarmStore = new Ext.data.ArrayStore({  
	            fields : ['alarm_type', 'alarm_name'],  
	            data : <%=DictionaryAction.getDictionaryCombo("79")%>,
	            sortInfo: {field: "alarm_name", direction: "ASC"}
	        });
	        
	            var configStore = new Ext.data.ArrayStore({  
	            fields : ['config_type', 'config_name'],  
	            data : <%=DictionaryAction.getDictionaryCombo("781")%>,
	            sortInfo: {field: "config_name", direction: "ASC"}
	        });
	        
	            var  editAlarmproFormPanel = new Ext.FormPanel({
				renderTo: 'editAlarmproFormDiv',
		        labelWidth: 70,
		        border: false,
		        bodyStyle: 'background-color:transparent;',
		         items: [{
		            layout:'form',
		            border: false,
		            bodyStyle: 'padding:5px;background-color:transparent;',
		            items:[{  
			                xtype:'combo',
			                hiddenName: 'alarm_type',
			                fieldLabel: '告警类型',
			                store: alarmStore,
			                mode : 'local',
			                triggerAction: "all",
			                valueField: 'alarm_type',
			                displayField: 'alarm_name',
			                allowBlank:false,
			                editable: false,
			                width: 230,
			                anchor:'98%'
			           },{
			                xtype:'combo',
			                hiddenName: 'config_type',
			                fieldLabel: '过滤类型',
			                store: configStore,
			                mode : 'local',
			                triggerAction: "all",
			                valueField: 'config_type',
			                displayField: 'config_name',
			                allowBlank:false,
			                editable: false,
			                width: 230,
			                anchor:'98%'
			           },{// 告警标题
			               xtype:'textfield',
			               id:'alarm_title',
			               name:'alarm_title',
			               fieldLabel:'过滤内容',
			               anchor:'98%',
			               allowBlank:false,
			               maxLength: 200
			           },{// id
			               xtype:'hidden',
			               id:'id',
			               name: 'id'
			           }]
		        }]
		    });
		    
		    // 发送请求-form初期化
			Anynote.ajaxRequest({
				baseParams: {userConfId:<%=userConfId%>},
				action: '${pageContext.request.contextPath}/getAlarmproCon.action',
				callback: function(jsonResult){
		     	    editAlarmproFormPanel.getForm().setValues(jsonResult);
				}
			});

		    // 保存按钮
		    $("#editAlarmpro-save-button").click(function(){
			    var form = editAlarmproFormPanel.getForm();
			    if(form.isValid()){
			    	// 发送请求
					Anynote.ajaxRequest({
						baseParams: form.getValues(),
						action: '${pageContext.request.contextPath}/updateAlarmpro.action?',
						callback: function(jsonResult){
						     alarmproConListGrid.getStore().reload();
						     editAlarmproWindow.close();
						},
						showWaiting: true,
						failureMsg: '保存失败.'
					});
				}
			});
			
		 	// 取消按钮
		    $("#editAlarmpro-cancel-button").click(function(){
		    	Ext.getCmp("buttonType").setValue("cancel");
		    	editAlarmproWindow.close();
			});
		});
	</script>
</head>
<body> 
<div id="editAlarmproDiv" style="width:100%;height:100%;">
	<div id="editAlarmproToolBarDiv"></div>
	<div id="editAlarmproFormDiv"></div>
</div>
</body>
</html>